package com.whjfxx.terminal.exceptions;

import com.whjfxx.terminal.enums.ResultEnum;

/**
 * Created by b.c on 2022/1/6 13:23
 */
public class BizException extends RuntimeException {

    private String code;

    private String logMessage;

    public String getCode() {
        return code;
    }

    private BizException(String code, String message) {
        super(message);
        this.code = code;
    }

    private BizException(String code, String message, String logMessage) {
        super(message);
        this.code = code;
        this.logMessage = logMessage;
    }

    private BizException(ResultEnum resultEnum) {
        this(resultEnum.code, resultEnum.msg);
    }

    private BizException(String message) {
        this(ResultEnum.fail.code, message);
    }

    public static BizException build(String message) {
        return new BizException(message);
    }

    public static BizException build(String message, String logMessage) {
        return new BizException(ResultEnum.fail.code, message, logMessage);
    }

    public static BizException build() {
        return new BizException(ResultEnum.error);
    }
}
